package de.freudenreichdesign.webshop.controller;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import de.freudenreichdesign.webshop.model.Article;
import de.freudenreichdesign.webshop.service.ArticleService;

@Controller
@RequestMapping("/index.html")
public class ProductGalleryController{

	@RequestMapping(method=RequestMethod.GET)
	public String showGallery(ModelMap modelMap) {
		List<Object> listOfAllArticlesAsObjects = ArticleService.getInstance().getListOfAllActiveArticles();
		Set<Article> listOfAllArticles = new HashSet<Article>();
		for (Object article : listOfAllArticlesAsObjects) {
			listOfAllArticles.add((Article)article);
		}
		modelMap.addAttribute("articleList", listOfAllArticles);
		return "homeView";
	}

}
